//
//  WeChatMomentsTests.m
//  WeChatMomentsTests
//
//  Created by Jiang on 2019/8/25.
//  Copyright © 2019 SilverFruity. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "MomentItem.h"
#import "MomentUser.h"
@interface WeChatMomentsTests : XCTestCase
@property (nonatomic, strong)SFHTTPClient *client;
@end

@implementation WeChatMomentsTests

- (void)setUp {
    self.client = [[SFHTTPClient alloc] initWithBaseUrl:[NSURL URLWithString:@"http://thoughtworks-ios.herokuapp.com/"]];
    self.client.requestGenerator = [SFRequestJSONSerializer new];
    
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
}

- (void)testMomentItem{
    
    SFHTTPPlugin *mapModelPlugin = [SFMapModelPlugin pluginWithModelClass:[MomentItem class]];
    [self.client requestWithMethod:@"GET" url:@"user/jsmith/tweets" parameters:nil plugin:mapModelPlugin completion:^(NSHTTPURLResponse * _Nonnull response, id  _Nullable data, NSError * _Nullable error) {
        XCTAssert([data isKindOfClass:[NSArray class]]);
        NSArray *items = data;
        XCTAssert([items.firstObject isKindOfClass:[MomentItem class]]);
        CFRunLoopStop(CFRunLoopGetMain());
    }];
    CFRunLoopRun();
}
- (void)testMomentUser{
    
    SFHTTPPlugin *mapModelPlugin = [SFMapModelPlugin pluginWithModelClass:[MomentUser class]];
    [self.client requestWithMethod:@"GET" url:@"user/jsmith" parameters:nil plugin:mapModelPlugin completion:^(NSHTTPURLResponse * _Nonnull response, id  _Nullable data, NSError * _Nullable error) {
        MomentUser *user = data;
        XCTAssert([data isKindOfClass:[MomentUser class]]);
        XCTAssert(user.profile_image != nil);
        CFRunLoopStop(CFRunLoopGetMain());
    }];
    CFRunLoopRun();
}

@end
